var cracks = [
    [-860, -94],
    [-324, -514],
    [318, 26],
    [837, -874]
];

function act() {
    var a = cm.getReactor().getState();
    if (a == 2) {
        var f = cm.getPlayer().getPosition();
        for (var d = 0; d < cracks.length; d++) {
            if (Math.abs(f.x - cracks[d][0]) < 50 && Math.abs(f.y - cracks[d][1]) < 50) {
                var e = cm.addNumberForQuestInfo(35706, "crack", 1);
                cm.getReactor().forceHitReactor(cm.getPlayer(), 3);
                cm.onSetMapTagedObjectVisible(1, "crack" + (d + 1), 0);
                cm.onSetMapTagedObjectVisible(1, "crack" + (d + 1) + "_destroy", 0);
                cm.Hidden_background("crack" + (d + 1), 1, 0, 0, 0);
                cm.Hidden_background("crack" + (d + 1) + "_destroy", 1, 0, 0, 0);
                if (e == 4) {
                    cm.getWeatherEffectNotice("迷宫的门打开了。", 253, 15000, 1);
                    var b = ["up00", "down00", "left00", "right00", "exit00"];
                    b.forEach(function (g) {
                        if (cm.getMap().getReactorByName(g).getState() == 1) {
                            cm.getMap().getReactorByName(g).forceHitReactor(cm.getPlayer(), 2)
                        }
                    })
                }
                return
            }
        }
        var c = cm.getReactor().getName();
        cm.getReactor().forceHitReactor(cm.getPlayer(), 3);
        cm.getReactor().delayedDestroyReactor(0);
        cm.getMap().spawnReactorIfNotExist(9405007, 0, f.x, f.y, 0, c)
    } else {
        cm.getReactor().forceHitReactor(cm.getPlayer(), 1)
    }
}
var status = -1;
var selectionLog = [];

function start() {
    action(1, 0, 0)
}

function action(d, c, b) {
    if (status == 0 && d == 0) {
        cm.dispose();
        return
    }
    var e = cm.getPlayer().getPosition();
    (d == 1) ? status++ : status--;
    selectionLog[status] = b;
    var a = -1;
    if (status <= a++) {
        cm.dispose()
    } else {
        if (status === a++) {
            for (var a = 0; a < cracks.length; a++) {
                if (Math.abs(e.x - cracks[a][0]) < 50 && Math.abs(e.y - cracks[a][1]) < 50) {
                    cm.onSetMapTagedObjectVisible(1, "crack" + (a + 1), 0);
                    cm.onSetMapTagedObjectVisible(1, "crack" + (a + 1) + "_destroy", 0);
                    cm.Hidden_background("crack" + (a + 1), 1, 0, 0, 0);
                    cm.Hidden_background("crack" + (a + 1) + "_destroy", 1, 0, 0, 0);
                    break
                }
            }
            cm.dispose()
        }
    }
};